package ldk.util.layoutmanagers;

import android.app.Activity;
import android.content.res.Configuration;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.View;
import android.widget.EditText;
import android.widget.LinearLayout;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import ldk.util.layoutmanagers.adapter.TagsAdapter;

/**
 * Created by ldkxingzhe@163.com on 2017/9/1.
 */

public class LinearLayoutWithKeyboardActivity extends Activity {
    private static final String TAG = "LinearLayout";

    @BindView(R.id.recycler_view)
    RecyclerView recyclerView;
    @BindView(R.id.edit)
    EditText edit;


    private List<String> dataList = new ArrayList<>();
    private TagsAdapter adapter = new TagsAdapter(dataList);

    private LinearLayoutManager linearLayoutManager;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_linear_layout);
        ButterKnife.bind(this);
        linearLayoutManager = new LinearLayoutManager(this);
        recyclerView.setLayoutManager(linearLayoutManager);
        dataList.addAll(Arrays.asList("中国1", "美国", "俄罗斯", "德国", "法国1", "意大利", "日本", "韩国", "英国1", "西班牙",
                "吃的", "喝的百事可乐还是可口可乐", "谁的天涯明月刀", "我的中华人民共和国", "天涯", "令牌1", "汉堡, 鸡翅， 牛排， 盒饭",
                "炸鸡", "肥牛", "又一只肥牛， 可以了吗", "鸡腿1", "哈哈",
                "中国1", "美国", "俄罗斯", "德国", "法国1", "意大利", "日本", "韩国", "英国1", "西班牙",
                "吃的", "喝的百事可乐还是可口可乐", "谁的天涯明月刀", "我的中华人民共和国", "天涯", "令牌1", "汉堡, 鸡翅， 牛排， 盒饭",
                "炸鸡", "肥牛", "又一只肥牛， 可以了吗", "鸡腿1", "哈哈"));

        recyclerView.setAdapter(adapter);
        edit.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
            @Override
            public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
                View current = getCurrentFocus();
                Log.v(TAG, "oldTop: " + oldTop + ", new Top: " + top + ", and current is " + current + ", and " + edit.isInputMethodTarget());
            }
        });
    }

    @Override
    public void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
        Log.v(TAG, "onConfigurationChanged");
    }
}
